﻿using KinonekoSoftware.CodariaDB.Documents.Shenanigans;

namespace KinonekoSoftware.Studio.Models.Shenanigans.Talking
{
    public sealed class UltraTipMSG : SystemMSG<UltraTipTalking>
    {
        public override void Update(Character character)
        {
            RaiseUpdated(nameof(Mention));
            RaiseUpdated(nameof(Text));
            RaiseUpdated(nameof(Tails));
        }
        
        
        public override bool IsCompleted(out string err)
        {
            if (string.IsNullOrEmpty(Tails) ||
                string.IsNullOrEmpty(Mention) ||
                string.IsNullOrEmpty(Text))
            {
                err = "不能发送空白的消息!";
                return false;
            }
            
            err = string.Empty;
            return true;
        }
        
        public override TalkingObject Duplicate() => new UltraTipTalking { Id = ID.Get() };

        
        public string Tails
        {
            get => TargetObject.Tails;
            set
            {
                TargetObject.Tails = value;
                RaiseUpdated();
            }
        }
        
        public string Text
        {
            get => TargetObject.Text;
            set
            {
                TargetObject.Text = value;
                RaiseUpdated();
            }
        }
        
        public string Mention
        {
            get => TargetObject.Mention;
            set
            {
                TargetObject.Mention = value;
                RaiseUpdated();
            }
        }

        public override string FullText => $"{Mention}{Text}{Tails}";
    }
}